package com.sixkey.controller.app;

import com.sixkey.entity.Room;
import com.sixkey.entity.vo.RoomDetailVo;
import com.sixkey.response.Response;
import com.sixkey.service.IRoomService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * ClassName: ApiRoomController
 * Package: com.sixkey.controller.api
 * Description:
 *
 * @Author: @weixueshi
 * @Create: 2023/10/7 - 23:53
 * @Version: v1.0
 */
@Slf4j
@Validated
@CrossOrigin
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/room")
public class ApiRoomController {

    private final IRoomService roomService;

    /**
     * 小程序端分页获取会议室数据
     * @return
     */
    @GetMapping("/list/{pageNo}/{pageSize}")
    public Response list(@PathVariable("pageNo") Integer pageNo,
                         @PathVariable("pageSize") Integer pageSize,
                         String roomName) {
        log.info("小程序端分页获取会议室数据请求进来");
        Map<String,Object> roomPage = roomService.apiQueryList(pageNo,pageSize,roomName);
        return Response.success(roomPage);
    }

    /**
     * 小程序端立即预约页面获取会议室数据
     * @return
     */
    @GetMapping("/roomList")
    public Response getMeetRoomData() {
        log.info("小程序端立即预约页面获取会议室数据请求进来");
        List<Room> roomList = roomService.getMeetRoomData();
        return Response.success(roomList);
    }

    /**
     * 小程序端会议室详情页
     * @return
     */
    @GetMapping("/detail/{id}")
    public Response getDetail(@PathVariable("id") int id) {
        log.info("小程序端会议室详情页请求进来");
        RoomDetailVo meetRoom = roomService.getMeetRoomDetails(id);
        return Response.success(meetRoom);
    }
}
